package com.aiit.datamanager.dao;

import com.aiit.datamanager.entity.LoginTicket;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 *
 */
@Mapper
@Repository
public interface LoginTicketMapper {
    //用注解写sql, 把几个字符串连接起来生成sql, 注意数据库中的是下划线, java类中是驼峰
    @Insert({"insert into login_ticket(employee_id, ticket, status, expired_time) " +
            "values (#{employeeId}, #{ticket}, #{status}, #{expiredTime})"})
    @Options(useGeneratedKeys = true, keyProperty = "id")//主键自动生成
    int insertLoginTicket(LoginTicket loginTicket);

    @Select({"select * from login_ticket where ticket = #{ticket}"})
    LoginTicket selectByTicket(String ticket);

    @Update({"update login_ticket set status = #{status} where ticket = #{ticket} "})
    int updateStatus(String ticket, int status);//只改状态, 不删除
}
